package com.liuche.pictureserver.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;

/**
 * 责任链枚举信息
 *
 * @author liuche
 */
@Getter
@AllArgsConstructor
public enum ProcessEnum {
    PICTURE_UPLOAD("picture_upload", "图片上传", "pictureUploadProcessTemplate"),
    ;
    private final String code;

    private final String desc;

    private final String beanName;

    /**
     * 根据code得到责任链信息
     *
     * @param code 编码
     * @return 结果
     */
    public static ProcessEnum getByCode(String code) {
        for (ProcessEnum value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }

    /**
     * 得到所有责任链信息
     *
     * @return 结果
     */
    public static List<ProcessEnum> getAll() {
        return Arrays.asList(values());
    }
}
